﻿Module Inisialitation

    Public Connection As New cls_connection
    Public Validation As New cls_validation
    Public Db As New cls_database

    Structure STR_AUTH
        Dim User As String
        Dim nim As String
        Dim Tipe As Integer
        Dim TipeDeskripsi As String
    End Structure

    Public Auth As STR_AUTH

    Public Structure STRUK_APP
        Dim Version As String
        Dim PATH_APP As String          ' C:\Program File\produksi\
        Dim PATH_IMG As String          ' C:\Program File\produksi\
    End Structure

    Public APP As STRUK_APP

    Public Sub InisialisasiAplikasi()

        APP.Version = "1.0"

        APP.PATH_APP = My.Application.Info.DirectoryPath.ToString & "\"
        APP.PATH_IMG = My.Application.Info.DirectoryPath.ToString & "\FOTO\"

        '# cek direktori, jika tidak ada maka buat directori baru
        If My.Computer.FileSystem.DirectoryExists(APP.PATH_IMG) = False Then
            My.Computer.FileSystem.CreateDirectory(APP.PATH_IMG)
        End If

        Dim PathConfig As String = My.Application.Info.DirectoryPath.ToString & "\config.txt"

        '# load connection string
        If My.Computer.FileSystem.FileExists(PathConfig) Then
            Dim strConect As String = My.Computer.FileSystem.ReadAllText(PathConfig)
            Connection.initConnection(strConect)
        Else
            MsgBox("Tidak ada pengaturan ke Database!" & vbCrLf & vbCrLf & "Lakukan pengaturan ke database", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "Psean")
            End
        End If

    End Sub

End Module
